CC	= g++
INCL	= -I./ -I../ -I/usr/include/ 
COMP	= ${CC} -c ${INCL} -g -Wall -O2
LINK	= ${CC} ${INCL} -lboost_thread  -ldl -g

default: main.o server.o message.o fastcgi.o logging.o stdoutloglistener.o 
	${LINK} -o webby main.o server.o message.o fastcgi.o logging.o stdoutloglistener.o

main.o: main.cxx server.hxx message.hxx config.hxx fastcgi.hxx logging.hxx
	${COMP} main.cxx

server.o: server.cxx server.hxx message.hxx config.hxx fastcgi.hxx logging.hxx
	${COMP} server.cxx

message.o: message.cxx message.hxx config.hxx  logging.hxx
	${COMP} message.cxx

fastcgi.o: fastcgi.cxx fastcgi.hxx config.hxx
	${COMP} fastcgi.cxx

logging.o: logging.cxx logging.hxx loglistener.hxx 
	${COMP} logging.cxx

stdoutloglistener.o: stdoutloglistener.cxx stdoutloglistener.hxx loglistener.hxx
	${COMP} stdoutloglistener.cxx

basemodule.o: basemodule.cxx basemodule.hxx module.hxx
	${COMP} -fpic basemodule.cxx

cachemodule.o: cachemodule.cxx cachemodule.hxx module.hxx
	${COMP} -fpic cachemodule.cxx

modules: basemodule.so cachemodule.so

basemodule.so: basemodule.o 
	${LINK} -shared -Wl,-soname,basemodule.so.1 -o modules/basemodule.so basemodule.o

cachemodule.so: cachemodule.o 
	${LINK} -shared -Wl,-soname,cachemodule.so.1 -o modules/cachemodule.so cachemodule.o

clean:
	rm -f *.o
	rm -f modules/*.so	
	rm -f ./webby
	rm -rf modules
	mkdir modules
